load("//toolchains/sysimage:toolchain.bzl", "vfat_image")

package(default_visibility = ["//rs:ic-os-pkg"])

exports_files([
    "grubenv",
    "guestos_grub.cfg",
    "hostos_grub.cfg",
    "setupos_grub.cfg",
    "guestos_boot_args.template",
    "hostos_boot_args.template",
    "setupos_boot_args.template",
])

genrule(
    name = "build-bootloader-tree",
    srcs = [],
    outs = [
        "bootloader-tree.tar",
    ],
    cmd = "$(location build-bootloader-tree.sh) -o $@",
    tags = ["manual"],
    target_compatible_with = [
        "@platforms//os:linux",
    ],
    tools = ["build-bootloader-tree.sh"],
)

vfat_image(
    name = "partition-esp.tzst",
    src = ":bootloader-tree.tar",
    partition_size = "100M",
    subdir = "boot/efi",
    tags = ["manual"],
    target_compatible_with = [
        "@platforms//os:linux",
    ],
)
